#pragma once

#include "SqlResult.h"

#ifdef DBMS_USE_ODBC

#if defined( WIN32 ) || defined ( WIN64 )

#include <windows.h>
#include <Odbcinst.h>
#include <Sql.h>
#include <sqlext.h>
#include <Sqltypes.h>
#include <Sqlucode.h>
#include <Msdasql.h>
#include <Msdadc.h>

#define ODBCSUCCESS(rc) ((rc==SQL_SUCCESS)||(rc==SQL_SUCCESS_WITH_INFO))

LIBDBC_BEGIN_NAMESPACE

class OdbcResult : public SqlResult
{
public:
  OdbcResult(SQLHSTMT hstmt, SQLHDBC hdbc);
  virtual ~OdbcResult();

  unsigned int getColumnCount();
  char* getFieldName(int field, char* buffer, int len);
  bool next();
  
  char* getString(int field, char* buffer, int len);
  int getInt(int field);
  long getLong(int field);
  double getDouble(int field);

  bool getStringExt(int field, char* buffer, int len);
  bool getInt(int field, int* pvalue);
  bool getLong(int field, long* pvalue);
  bool getDouble(int field, double* pvalue);

  bool getBinaryLength(int field, unsigned long* len);
  bool getBinary(int field, unsigned char* pBuffer, int buflen);

protected:
  SQLHSTMT _hResult;
  SQLHDBC  _hdbc;
  int _cols; 

};

LIBDBC_END_NAMESPACE

#endif

#endif